<template>
    <div class="centherBigbox">
        <XSwitch v-model="theme" small :onChange="handleChange" rightText="深色" leftText="浅色"></XSwitch>
    </div>
</template>

<script setup>
import XSwitch from '@/components/XSwitch.vue'
import { onMounted, ref } from 'vue'
import { userThemeStore } from '@/stores/userTheme.js'
// 使用 useUserThemeStore 来获取 store 实例
const userTheme = userThemeStore()

const theme = ref(true)
// 定义切换主题的函数
const handleChange = (val) => {
    userTheme.toggleTheme()
}
onMounted(() => {
    theme.value = userTheme.theme == 'dark' ? true : false
})
</script>

<style scoped lang='scss'>
.centherBigbox {
    transition: all .5s ease-in-out;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    flex-direction: column;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.ceshi {
    padding: 10px;
}
</style>
